Base class for vector renderer implementations (SVG, Canvas). Handles the DOM container of the renderer, its bounds, and its zoom animation.
矢量渲染器实现(SVG、画布)的基类。处理渲染器的DOM容器、其边界和缩放动画。
A Renderer works as an implicit layer group for all Paths – the renderer itself can be added or removed to the map. All paths use a renderer, which can be implicit (the map will decide the type of renderer and use it automatically) or explicit (using the renderer option of the path).
Do not use this class directly, use SVG and Canvas instead.
渲染器作为所有路径的隐式层组工作-渲染器本身可以添加或删除到地图中。所有路径都使用渲染器,它可以是隐式的(贴图将决定渲染器的类型并自动使用)或显式的(使用路径的渲染器选项)。不要直接使用此类,请改用SVG和Canvas。
Options
| Option | Type | Default | Description |
|---|---|---|---|
padding |
Number |
0.1 |
How much to extend the clip area around the map view (relative to its size) e.g. 0.1 would be 10% of map view in each direction
在地图视图周围延伸剪辑区域的范围(相对于其大小),例如0.1将是每个方向上地图视图的10% |
| Option | Type | Default | Description |
|---|---|---|---|
pane |
String |
'overlayPane' |
By default the layer will be added to the map’s overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
默认情况下,图层将添加到地图的覆盖窗格中。默认情况下,覆盖此选项将导致图层放置在另一个窗格上。 |
attribution |
String |
null |
String to be shown in the attribution control, e.g. “© OpenStreetMap contributors”. It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
属性控件中显示的字符串,例如“©OpenStreetMap贡献者”。它描述了图层数据,通常是版权所有者和瓷砖供应商的法律义务。 |
Events
| Event | Data | Description |
|---|---|---|
update |
Event |
Fired when the renderer updates its bounds, center and zoom, for example when its map has moved
当渲染器更新其边界、中心和缩放时激发,例如当其贴图移动时 |
| Event | Data | Description |
|---|---|---|
popupopen |
PopupEvent |
Fired when a popup bound to this layer is opened
打开绑定到此层的弹出窗口时激发 |
popupclose |
PopupEvent |
Fired when a popup bound to this layer is closed
当绑定到此层的弹出窗口关闭时激发 |
| Event | Data | Description |
|---|---|---|
tooltipopen |
TooltipEvent |
Fired when a tooltip bound to this layer is opened.
打开绑定到此层的工具提示时激发。 |
tooltipclose |
TooltipEvent |
Fired when a tooltip bound to this layer is closed.
当绑定到此层的工具提示关闭时激发。 |
Methods
| Method | Returns | Description |
|---|---|---|
addTo(<Map|LayerGroup> map) |
this |
Adds the layer to the given map or layer group.
将图层添加到给定的贴图或图层组。 |
remove() |
this |
Removes the layer from the map it is currently active on.
从当前处于活动状态的贴图中删除图层。 |
removeFrom(<Map> map) |
this |
Removes the layer from the given map
从给定地图中删除图层 |
removeFrom(<LayerGroup> group) |
this |
Removes the layer from the given LayerGroup
从给定图层组中删除图层 |
getPane(<String> name?) |
HTMLElement |
Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.
返回表示地图上命名窗格的HTMLElement。如果省略了名称,则返回此层的窗格。 |
getAttribution() |
String |
Used by the attribution control, returns the attribution option.
由归因控件使用,返回归因选项。 |
| Method | Returns | Description |
|---|---|---|
bindPopup(<String|HTMLElement
|
this |
Binds a popup to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
使用传递的内容将弹出窗口绑定到层,并设置必要的事件侦听器。如果传递了一个函数,它将接收该层作为第一个参数,并应返回一个String或HTMLElement。 |
unbindPopup() |
this |
Removes the popup previously bound with bindPopup.
删除先前绑定bindPopup的弹出窗口。 |
openPopup(<LatLng> latlng?) |
this |
Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.
在指定的锁定位置打开绑定的弹出窗口,如果未通过锁定,则在默认的弹出窗口定位点打开绑定的。 |
closePopup() |
this |
Closes the popup bound to this layer if it is open.
关闭绑定到此层的弹出窗口(如果它是打开的)。 |
togglePopup() |
this |
Opens or closes the popup bound to this layer depending on its current state.
根据当前状态打开或关闭绑定到此层的弹出窗口。 |
isPopupOpen() |
boolean |
Returns true if the popup bound to this layer is currently open.
如果绑定到此层的弹出窗口当前处于打开状态,则返回true。 |
setPopupContent(<String|
|
this |
Sets the content of the popup bound to this layer.
设置绑定到此层的弹出窗口的内容。 |
getPopup() |
Popup |
Returns the popup bound to this layer.
返回绑定到此层的弹出窗口。 |
| Method | Returns | Description |
|---|---|---|
bindTooltip(<String|HTMLElement
|
this |
Binds a tooltip to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
将工具提示与传递的内容绑定到层,并设置必要的事件侦听器。如果传递了一个函数,它将接收该层作为第一个参数,并应返回一个String或HTMLElement。 |
unbindTooltip() |
this |
Removes the tooltip previously bound with bindTooltip.
删除以前与bindTooltip绑定的工具提示。 |
openTooltip(<LatLng> latlng?) |
this |
Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.
在指定的锁定位置打开绑定的工具提示,如果未传递锁定,则在默认的工具提示锚定位置打开绑定工具提示。 |
closeTooltip() |
this |
Closes the tooltip bound to this layer if it is open.
关闭绑定到此图层的工具提示(如果该图层处于打开状态)。 |
toggleTooltip() |
this |
Opens or closes the tooltip bound to this layer depending on its current state.
根据当前状态打开或关闭绑定到此层的工具提示。 |
isTooltipOpen() |
boolean |
Returns true if the tooltip bound to this layer is currently open.
如果绑定到此层的工具提示当前处于打开状态,则返回true。 |
setTooltipContent(<String|
|
this |
Sets the content of the tooltip bound to this layer.
设置绑定到此层的工具提示的内容。 |
getTooltip() |
Tooltip |
Returns the tooltip bound to this layer.
返回绑定到此层的工具提示。 |
| Method | Returns | Description |
|---|---|---|
on(<String> type, <Function>
|
this |
Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').
向对象的特定事件类型添加侦听器函数(fn)。您可以选择指定侦听器的上下文(this关键字将指向的对象)。您还可以传递几个空格分隔的类型(例如“click dblclick”)。 |
on(<Object> eventMap) |
this |
Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
添加一组类型/侦听器对,例如{click:onClick,mousemove:onMouseMove} |
off(<String> type, <Function>
|
this |
Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.
删除以前添加的侦听器函数。如果没有指定函数,它将从对象中删除该特定事件的所有侦听器。请注意,如果您将自定义上下文传递给on,则必须将相同的上下文传递给off才能删除侦听器。 |
off(<Object> eventMap) |
this |
Removes a set of type/listener pairs.
删除一组类型/侦听器对。 |
off() |
this |
Removes all listeners to all events on the object. This includes implicitly attached events.
删除对象上所有事件的所有侦听器。这包括隐式附加的事件。 |
fire(<String> type, <Object>
|
this |
Fires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents.
激发指定类型的事件。您可以选择提供一个数据对象-侦听器函数的第一个参数将包含其属性。可以选择将事件传播到事件父级。 |
listens(<String> type,
|
Boolean |
Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.
如果特定事件类型附加了任何侦听器,则返回true。可以选择传播验证,如果父级附加了侦听器,验证将返回true。 |
once(…) |
this |
Behaves as on(…), except the listener will only get fired once and then removed.
表现为on(…),但监听器只会被解雇一次,然后被移除。 |
addEventParent(<Evented> obj) |
this |
Adds an event parent – an Evented that will receive propagated events
添加事件父级-将接收传播事件的Evented |
removeEventParent(<Evented> obj) |
this |
Removes an event parent, so it will stop receiving propagated events
删除事件父级,因此它将停止接收传播的事件 |
addEventListener(…) |
this |
Alias to on(…) |
removeEventListener(…) |
this |
Alias to off(…) |
clearAllEventListeners(…) |
this |
Alias to off() |
addOneTimeEventListener(…) |
this |
Alias to once(…) |
fireEvent(…) |
this |
Alias to fire(…) |
hasEventListeners(…) |
Boolean |
Alias to listens(…) |